MySQL

class MySQL(url: String, username: String, password: String, options: ConnectionPool.Options = ConnectionPool.Options()) : IMySQL(source)

The MySQL class provides a driver implementation for interacting with a MySQL database. It supports connection pooling, transactional operations, and executing SQL queries.

The connection URL should follow the nex pattern, as described by MySQL.

The generic format of the connection URL: mysql:///database?properties

Parameters

url

The connection URL for the MySQL database.

username

The username for authenticating with the database.

password

The password for authenticating with the database.

options

The optional configuration for the connection pool, such as min/max connections and timeout settings.

Constructors

Link copied to clipboard
constructor(url: String, username: String, password: String, options: ConnectionPool.Options = ConnectionPool.Options())

Types

Link copied to clipboard
class Cn(connection: Connection) : Connection

A concrete implementation of the Connection interface that manages a single database connection while ensuring thread-safety and proper lifecycle handling.

Link copied to clipboard
object Companion
Link copied to clipboard
class Tx(connection: Connection, closeConnectionAfterTx: Boolean) : Transaction

Represents a transaction implementation that provides functionality for managing and executing operations within a transactional context.

Functions

Link copied to clipboard
open suspend override fun acquire(): Result<Connection>
Link copied to clipboard
open suspend override fun begin(): Result<Transaction>
Link copied to clipboard
open suspend override fun close(): Result<Unit>
Link copied to clipboard
open suspend override fun execute(statement: Statement): Result<Long>
open suspend override fun execute(sql: String): <Error class: unknown class>
Link copied to clipboard
open suspend fun <T> fetchAll(sql: String, rowMapper: RowMapper<T>): Result<List<T>>
open suspend override fun fetchAll(statement: Statement): Result<ResultSet>
open suspend override fun fetchAll(sql: String): Result<ResultSet>
open suspend override fun <T> fetchAll(statement: Statement, rowMapper: RowMapper<T>): Result<List<T>>
Link copied to clipboard
open suspend override fun migrate(path: String, table: String, schema: String?, createSchema: Boolean, afterStatementExecution: suspend (Statement, Duration) -> Unit, afterFileMigration: suspend (Migration, Duration) -> Unit): Result<Migrator.Results>
Link copied to clipboard
open override fun poolIdleSize(): Int
Link copied to clipboard
open override fun poolSize(): Int
Link copied to clipboard
open suspend fun <T> transaction(f: suspend Transaction.() -> T): T